<template>
  <div>
    <el-form :inline="true" class="user-search">
      <el-form-item>
        <el-input placeholder="请输入内容" v-model="queryForm.name"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button title="查询" type="primary" icon="el-icon-search" @click="handleList">查询</el-button>
        <el-button type="success" @click="handleAdd">新增</el-button>
        <el-button type="danger">批量删除</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column type="selection" width="55">
      </el-table-column>
      <el-table-column prop="id" label="ID" width="60">
      </el-table-column>
      <el-table-column prop="name" label="优惠券名称" width="100">
      </el-table-column>
      <el-table-column prop="startTime" label="开始时间" width="155">
      </el-table-column>
      <el-table-column prop="endTime" label="结束时间" width="155">
      </el-table-column>
      <el-table-column prop="conditions" label="优惠条件" width="80">
      </el-table-column>
      <el-table-column prop="number" label="发布数量" width="80">
      </el-table-column>
      <el-table-column prop="cost" label="金额" width="60">
      </el-table-column>
      <el-table-column prop="introduce" label="说明" width="60">
      </el-table-column>
      <el-table-column prop="lqNum" label="领取数量" width="80">
      </el-table-column>
      <el-table-column prop="klqzs" label="每人可领取数量" width="120">
      </el-table-column>
      <el-table-column label="操作" show-overflow-tooltip>
        <template slot-scope="scope">
          <el-button type="danger" icon="el-icon-delete" circle></el-button>
          <el-button type="primary" icon="el-icon-edit" circle></el-button>
        </template>
      </el-table-column>
    </el-table>
    <br />
    <div align="center">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="queryForm.page"
        :page-sizes="[4, 10, 20, 50]" :page-size="queryForm.rows" layout="total, sizes, prev, pager, next, jumper"
        :total="queryForm.total">
      </el-pagination>
    </div>
    <el-dialog :title="dialogTitle" :visible.sync="dialogMergeForm">
      <el-form :model="mergeForm" :rules="rules">
        <el-form-item prop="name" label="优惠券名称" :label-width="100">
          <el-input v-model="mergeForm.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item prop="name" label="开始时间">
          <el-date-picker v-model="value1" type="date" placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item prop="name" label="结束时间">
          <el-date-picker v-model="value1" type="date" placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item prop="floor" label="优惠条件" :label-width="formLabelWidth">
          <el-input v-model="mergeForm.floor" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item prop="people" label="发布数量" :label-width="formLabelWidth">
          <el-input v-model="mergeForm.people" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item prop="size" label="金额" :label-width="formLabelWidth">
          <el-input v-model="mergeForm.size" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item prop="size" label="说明" :label-width="formLabelWidth">
          <el-input v-model="mergeForm.size" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item prop="size" label="领取数量" :label-width="formLabelWidth">
          <el-input v-model="mergeForm.size" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item prop="size" label="每人可领取张数" :label-width="formLabelWidth">
          <el-input v-model="mergeForm.size" autocomplete="off"></el-input>
        </el-form-item>
        
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogMergeForm = false">取 消</el-button>
        <el-button type="primary">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        dialogTitle: '新建优惠券',
        tableData: [],
        dialogMergeForm: false,
        dynamicTags: [],
        inputVisible: false,
        inputValue: '',
        dialogImageUrl: '',
        dialogVisible: false,
        queryForm: {
          name: null,
          startTime: null,
          endTime: null,
          conditions: null,
          number: null,
          cost: null,
          introduce: null,
          lq_num: null,
          klqzs: null,
          ruleDec: null,
          page: 1,
          rows: 4,
          total: -1
        },
        mergeForm: {
          id: null,
          sellerId: null,
          name: null,
          startTime: null,
          endTime: null,
          conditions: null,
          number: null,
          cost: null,
          type: null,
          introduce: null,
          lqNum: null,
          klqzs: null,
          time: null,
          ruleDec: null
        },
        rules: {
          name: [{
            required: true,
            message: '房型名字',
            trigger: 'blur'
          }],
          oprice: [{
            required: true,
            message: '门市价',
            trigger: 'blur'
          }],
          floor: [{
            required: true,
            message: '楼层',
            trigger: 'blur'
          }],
          people: [{
            required: true,
            message: '可住人数',
            trigger: 'blur'
          }],
          size: [{
            required: true,
            message: '床型尺寸',
            trigger: 'blur'
          }],
        },
      }
    },
    created() {
      this.doList()
    },
    methods: {
      doList: function() {
        this.axios.post(this.axios.urls.DYM_HOTELCOUPONS_LIST, this.queryForm).then((response) => {
          console.log(response);
          this.tableData = response.data.result;
          this.queryForm.page = response.data.page
          this.queryForm.rows = response.data.rows
          this.queryForm.total = response.data.total
        })
      },
      handleList: function() {
        this.doList()
      },
      //分页
      handleSizeChange(rows) {
        this.queryForm.page = 1
        this.queryForm.rows = rows
        this.doList()
      },
      handleCurrentChange(page) {
        this.queryForm.page = page
        this.doList()
      },
      handleAdd: function() {
        this.dialogTitle = '新建酒店房型',
          this.dialogMergeForm = true
      },
      handelEdit: function() {
        this.dialogTitle = '编辑酒店房型',
          this.mergeForm.name = null
        this.mergeForm.classify = null
        this.mergeForm.oprice = null
        this.mergeForm.tags = null
        this.mergeForm.logo = null
        this.mergeForm.facilities = null
        this.mergeForm.floor = null
        this.mergeForm.people = null
        this.mergeForm.size = null

        this.dialogMergeForm = true
      }
    }
  }
</script>

<style scoped>
  .user-search {
    margin-top: 20px;
  }

  .userRole {
    width: 100%;
  }

  .el-row {
    margin-bottom: 20px;

    &:last-child {
      margin-bottom: 0;
    }
  }

  .el-col {
    border-radius: 4px;
  }

  .bg-purple-dark {
    background: #99a9bf;
  }

  .bg-purple {
    background: #d3dce6;
  }

  .bg-purple-light {
    background: #e5e9f2;
  }

  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }

  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }

  .modal-dialog {
    z-index: 10000 !important;
  }

  .el-tag+.el-tag {
    margin-left: 10px;
  }

  .button-new-tag {
    margin-left: 10px;
    height: 32px;
    line-height: 30px;
    padding-top: 0;
    padding-bottom: 0;
  }

  .input-new-tag {
    width: 90px;
    margin-left: 10px;
    vertical-align: bottom;
  }
</style>
